package Game;

import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glTranslatef;
import java.util.Vector;
import Engine.loader.Loader;
import Engine.loader.obj.ModelObj;

public class GameModel extends GameObject {
	
	protected Vector<ModelObj> modelList = new Vector<ModelObj>();
	
	public boolean key = false;
	
	public GameModel(float x, float y, float z, String modelPath, String texturePath) {
		super(x, y, z);
		Loader loader = new Loader();
		loader.OBJ(modelPath, modelList, texturePath);
	}
	
	public GameModel(GameModel tank) {
		super(tank.x, tank.y, tank.z);
		this.modelList = (Vector<ModelObj>) tank.modelList.clone();
		
		this.rotateX = tank.rotateX;
		this.rotateY = tank.rotateY;
		this.rotateZ = tank.rotateZ;
	}

	@Override
	public void Update(long diftime) {
		if(key == true){
			for (ModelObj model : this.modelList) {
				model.update(diftime, this);
			}
		}
	}
	
	@Override
	public void Render() {
		for (ModelObj model : this.modelList) {
			glPushMatrix();
				glRotatef(model.rotateX, 1, 0, 0);
				glRotatef(model.rotateY, 0, 1, 0);
				glRotatef(model.rotateZ, 0, 0, 1);
				model.render(this);
			glPopMatrix();
		}
	}
}
